/**
 * 我的关注--筛选栏
 */

 import React,{PropTypes,Component,PureComponent}  from 'react';
 import {Button ,message ,Modal,Form,Row,Col,Card } from 'antd';
 import {connect} from 'dva';

 import {PolicyGroup} from './AttentionGroup';
 import PolicyGrouping from '../../component/NewPolicyGrouping';
 import style from './toolbar.less';
 const FormItem = Form.Item;

/**
 * [confirm description]
 * data [分组数据]
 * filterProduct [分组筛选结果]
 */
//工具栏
const confirm = Modal.confirm;
const Toolbar=({
  tag,
  data,
  dispatch,
  groupName,
  groupNumber,
  username,
  edit,
  isPublic,
  filterProduct
})=>{
  console.log("tool>>>>>",data,username);
  const type = 'edit';
  function deleteGroup(groupNumber) {
    console.log("groupNumber>>>", groupNumber);
    confirm({
      title: '您确定要删除此分组?',
      onOk() {
        dispatch({
          type:`${tag}/deletePolicyGroup`,
          payload: {
            groupNumber:groupNumber
          }
        })
        dispatch({
          type:`${tag}/setState`,
          payload: {
            filterProduct:[]
          }
        })
        dispatch({
          type:`${tag}/getPolicyGroup`,
        })
      },
      onCancel() {
        // message.error('删除失败');
      }
    });
  }
  return (
    <div>
      <Row type="flex" gutter={32} align="bottom">
        <Col style={{marginLeft:10}}>
          {/* 分组下拉框 */}
          <PolicyGroup
            tag={tag}
            data={data}
            dispatch={dispatch}
            groupName={groupName}
            username={username}
          />
        </Col>
        <Col>
          {/* 新建分组 */}
          <PolicyGrouping isPublic={isPublic}/>
        </Col>
        <Col>
          {/* 编辑分组 */}
          <PolicyGrouping
            type={type}
            groupName={groupName}
            groupNumber={groupNumber}
            edit={edit}
            isPublic={isPublic}
          />
        </Col>
        <Col>
          {/* 删除分组 */}
          <Button
            type='primary'
            onClick={() => deleteGroup(groupNumber)}
            disabled={groupNumber===''?true:false}
          >
            删除
          </Button>
        </Col>
      </Row>
    </div>
  )
}
 Toolbar.propTypes={}
 export default connect(({myattention})=>({myattention}))(Toolbar)
